if (!jsx3.lang.Class.forName("ux.cdb.admin.system.role.roleWizard.RoleInfoPane")) {
  jsx3.lang.Class.defineClass("ux.cdb.admin.system.role.roleWizard.RoleInfoPane", 
  ux.megatron.gui.WizardPanel, 
  null, 
  function(block){
    /**
     * instance initializer
     * @param strName {String} unique name distinguishing this object from all other JSX GUI objects in the JSX application
     * @param vntLeft {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
     * @param vntTop {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
     * @param vntWidth {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
     * @param vntHeight {int|String} either a number (i.e, 12, 30, etc) or a number and a unit value (i.e., "25%", "36pt", etc); if a number is passed, pixels will be the assumed unit when painted to screen
     * @param strHTML {String} Text/HTML markup to place in the jsx3.gui.Block instance
     */
    block.prototype.init = function(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML){
      //call constructor for super class (the super expects the name of the object and the function that it is an instance of)
      this.jsxsuper(strName, vntLeft, vntTop, vntWidth, vntHeight, strHTML);
    };
    block.prototype.setData = function(record){
        var cdfDoc = jsx3.xml.CDF.Document.newDocument();
        cdfDoc.insertRecord(record);
        var me = this;
        setTimeout(function(){
            me.getDescendantOfName("blk_roleInfoProvider").setData(cdfDoc);
            me.getWizard().getDescendantOfName("windowBar").setDynamicProperty("jsxtext", "@cdb@System@Role@Wizard@EditTitle");
            me.getWizard().getDescendantOfName("windowBar").repaint();
        }, 0);
        this.mode = "edit";
        this.jsxid = record["jsxid"];
        this.role_id = record["jsxid"];

    };
    block.prototype.getWizard = function(){
        return this.getServer().getRootBlock().getDescendantsOfType("ux.cdb.admin.system.role.roleWizard.RoleWizard")[0];
    };
    block.prototype.getRoleBlock = function(){
        return this.getServer().getRootBlock().getDescendantsOfType("ux.cdb.admin.system.role.Role")[0];
    };
    block.prototype.enableFinish = function(){
        this.getAncestorOfType("ux.cdb.admin.system.role.roleWizard.RoleWizard").getDescendantOfName("buttonFinish").setEnabled(jsx3.gui.Form.STATEENABLED, true);
    };
    block.prototype.disableFinish = function(){
        this.getAncestorOfType("ux.cdb.admin.system.role.roleWizard.RoleWizard").getDescendantOfName("buttonFinish").setEnabled(jsx3.gui.Form.STATEDISABLED, true);
    };
    block.prototype.onNameChange = function(objTxt, objEVENT, strPREVIOUS, strVALUE){
        jsx3.log("onNameChange");
        //this.doValidate();
    };
    block.prototype.onTypeChange = function(objSel, objEVENT, strRECORDID){
        jsx3.log("onTypeChange");
        //this.doValidate();
    };
    block.prototype.onParentChange = function(objSel, objEVENT, strRECORDID){
        jsx3.log("onParentChange");
        //this.doValidate();
    };
    block.prototype.onDescribeChange = function(objTxt, objEVENT, strPREVIOUS, strVALUE){
        jsx3.log("onDescribeChange");
        //this.doValidate();
    };
    block.prototype.initialize = function(msg){
      this.wizard = this.getAncestorOfType("ux.megatron.gui.SteppedWizard");
    }

    block.prototype.onCancel = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL){
      this.doClose();
      return null; // return "NONE" to not advance panels
    };
    block.prototype.doClose = function(){
      this.getAncestorOfType("ux.cdb.admin.system.role.roleWizard.RoleWizard").doClose();
    };
    block.prototype.onCustomNav = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL){
      return null; // return "NONE" to not advance panels
    };
    block.prototype.displayTip = function(passed) {
        try{
            //console.log(this.wizard);
        if(!passed) {
            var tip = ux.megatron.Main.getServer().getDynamicProperty("@cdb@System@Role@ValidateFailedTip");
            this.wizard.getMessageLabel().setText(tip);
        } else {
            this.wizard.getMessageLabel().setText("");
        }
        } catch(ex) {
            alert(ex.message);
        }
        return passed;
    };
    block.prototype.onFinish = function(objWIZARD, objBUTTON, objEVENT, strCURRENTPANEL){
        if(this.getDescendantOfName("blk_roleInfoProvider").doValidate() === null){
            try{
                var recordRole = this.getDescendantOfName("blk_roleInfoProvider").getData();
                var objRole = recordRole.toJSON().record[0];
                //var mtx = this.getRoleBlock().getMatrix();
                //var typeDoc = jsx3.xml.CDF.Document.newDocument().loadXML(ux.megatron.Main.loadResource("ux/cdb/admin/system/role/docs/Type.xml", "ux.cdb.admin", "RoleTypeDoc", "xml"));
                //var parentDoc = jsx3.xml.CDF.Document.newDocument().loadXML(ux.megatron.Main.loadResource("ux/cdb/admin/system/role/docs/Parent.xml", "ux.cdb.admin", "RoleParentDoc", "xml"));
                if(this.mode == "edit"){
                    /*
                    mtx.insertRecordProperty(this.jsxid, "roleName", objRole["roleName"], false);
                    mtx.insertRecordProperty(this.jsxid, "roleTypeId", objRole["roleType"], false);
                    mtx.insertRecordProperty(this.jsxid, "roleType", typeDoc.getRecord(objRole["roleType"])["jsxtext"], false);
                    mtx.insertRecordProperty(this.jsxid, "parentRoleId", objRole["parentRoleId"], false);
                    mtx.insertRecordProperty(this.jsxid, "parentRole", parentDoc.getRecord(objRole["parentRoleId"])["jsxtext"], false);
                    mtx.insertRecordProperty(this.jsxid, "roleDesc", objRole["roleDesc"], false);
                    */
                    objRole["sysRoleId"] = this.jsxid;
                    ux.megatron.util.Dwr.callDwr("RoleMgrUCC", "updateSysRole", [objRole], this, function(dwrObject){
                        //console.log(dwrObject);
                    }, "RoleMgrUCC");
                } else {
                    /*
                    try{
                        var record = recordRole.getFirstChild();
                        record.setAttribute("roleType", typeDoc.getRecord(record.getAttribute("roleType"))["jsxtext"]);
                        record.setAttribute("parentRoleId", parentDoc.getRecord(record.getAttribute("parentRoleId"))["jsxtext"]);
                        var jsxid = jsx3.xml.CDF.getKey();
                        record.setAttribute("jsxid", jsxid);
                        record.setAttribute("roleId", jsxid);
                        mtx.insertRecordNode(record);
                    } catch(ex){
                        //alert(ex.message);
                    }
                    */
                    ux.megatron.util.Dwr.callDwr("RoleMgrUCC", "addSysRole", [objRole], this, function(dwrObject){
                        //console.log(dwrObject);
                    }, "RoleMgrUCC");
                }
                /*
                mtx.repaintData();
                */
                this.doClose();
                this.mode = null;
            } catch(ex) {
                alert(ex);
            }
        } else {
            this.displayTip(false)
        };
        return "NONE";
    }
    
    block.prototype.onBeforeShow = function(objWIZARD, objBUTTON, objEVENT, strLASTPANEL){
      if (!this.getChild(0)) {
        var me = this;
        ux.megatron.Main.loadUIResourceAsync(me, "ux.cdb.admin", "ux/cdb/admin/system/role/roleWizard/step1/ui/RoleInfoContent.xml", me, me.initialize);
      }
      return null; // return "NONE" to not advance panels
    }
    
    block.prototype.onAfterHide = function(objWIZARD, objBUTTON, objEVENT, strNEXTPANEL){
      return null; // return "NONE" to not advance panels
    }
  });
}
